import {
  Controller,
  Post,
  Body,
  UseInterceptors,
  UploadedFile,
  UploadedFiles,
} from '@nestjs/common';
import { FileInterceptor, FilesInterceptor } from '@nestjs/platform-express';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { ImageUploadService } from './image-upload.service';


@ApiTags('上传')
@Controller('upload')
export class ImageUploadController {
constructor(
  private readonly imageUploadService:ImageUploadService
){}

  @Post('album')
  @ApiOperation({ summary: '单个图片上传' })
  @UseInterceptors(FileInterceptor('file')) //配置文件拦截器  file 为上传文件的key
  upload(@Body() params, @UploadedFile() file) {
    return this.imageUploadService.upload(params,file)
  }

  @Post('albums')
  @ApiOperation({ summary: '多个图片上传' })
  @UseInterceptors(FilesInterceptor('files')) //配置文件拦截器  files 为上传文件的key
  uploadFiles(@Body() params, @UploadedFiles() files) {
    return this.imageUploadService.uploadFiles(params,files)
  }
}
